﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL_NhaSach;
using BLL;
namespace BLL_NhaSach
{
    public class LichSuNoBLL : IProcessData
    {
        QLNhaSachEntities db;
        public LichSuNoBLL(String cnStr)
        {
            db = new QLNhaSachEntities(cnStr);
        }
        public object getAllData()
        {
            return (from ls in db.LichSuNoes select new {ls.MaLSN,ls.KhachHang.TenKH,ls.NgayPS,ls.GiaTriDau,ls.GiaTriPS});
        }

        public object findObjects(string find_content)
        {
            throw new NotImplementedException();
        }

        public object findObjects(int find_content)
        {
            return db.LichSuNoes.SingleOrDefault(p => p.MaLSN == find_content);
        }

        public object sort(string Col_Name, bool state)
        {
            throw new NotImplementedException();
        }

        public bool addObject(object addObj)
        {
            LichSuNo ls = (LichSuNo)addObj;
            try
            {
                db.LichSuNoes.AddObject(ls);
                db.SaveChanges();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        public bool deleteObject(int id)
        {
            throw new NotImplementedException();
        }

        public bool updateObject(object updateObj)
        {
            throw new NotImplementedException();
        }
    }
}
